package com.lanjiu.lib.imclient.bus;

/**
 * @description:
 * @author: Panwei
 * @date: 2019/11/6 21:02
 */
public class MessageEvent {

    private int event;
    private int code;
    private String msg;
    private String data; // 可以使用泛型，此处用字符串处理
    private int action;

    public MessageEvent(int event) {
        this.event = event;
    }

    public static MessageEvent createReaderEvent(int action) {
        return new MessageEvent(EventConstants.Event.SERVER_MESSAGE_READER, action);
    }

    public static MessageEvent createSenderEvent(int action) {
        return new MessageEvent(EventConstants.Event.SERVER_MESSAGE_SENDER, action);
    }

    public static MessageEvent cerateUiRefresh(int action) {
        return new MessageEvent(EventConstants.Event.UI_REFRESH_NOTIFICATION, action);
    }

    public static MessageEvent createUiRefreshWidthData(int action, String data) {
        MessageEvent event = new MessageEvent(EventConstants.Event.UI_REFRESH_NOTIFICATION, action);
        event.setData(data);
        return event;
    }

    private MessageEvent(int event, int action) {
        this.event = event;
        this.action = action;
    }

    public void setResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int event() {
        return event;
    }

    public int code() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String msg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String data() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public int action() {
        return action;
    }

    public void setAction(int action) {
        this.action = action;
    }

    @Override
    public String toString() {
        return "MessageEvent{" +
                "event=" + event +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                ", data='" + data + '\'' +
                ", action=" + action +
                '}';
    }
}
